package com.remote
{
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.remoting.RemoteObject;
	
	public class SystemService
	{		
		private var ro:RemoteObject;
		public function SystemService()
		{
			ro = new mx.rpc.remoting.RemoteObject("systemming");
			ro.source = "system.SystemService";			
		}
		
		public function Signin(userID:String, password:String, strPssNO:String, responder:IResponder = null ):void
		{
			try
			{
				var asyncToken:AsyncToken  = ro.Signin(userID, password, strPssNO);			
				if( responder != null )
					asyncToken.addResponder(responder);	
			} 
			catch(error:Error) 
			{
				Alert.show(error.message,"ASM Message");	
			}				    
		}
		
		public function insert_sys_log(strAction:String, strfrmAction:String, strbtnAction:String, strUserId:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.insert_sys_log(strAction, strfrmAction, strbtnAction, strUserId);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function updatePassWord(strUserId:String, strPassWord:String , responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.updatePassWord(strUserId, strPassWord);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getRoleTrans(roleID:String , responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getRoleTrans(roleID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getRoleTransEdit(roleID:String , responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getRoleTransForUsersEdit(roleID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getRoleTransForUsers(userID:String , responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getRoleTransForUsers(userID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getBranchIDForUser(userID:String , responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getBranchIDForUser(userID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getBranchs(responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getBranchs();
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getMenu(userID:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getMenu(userID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}	
		
		public function getUsers(userID:String, roleID:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getUsers(userID, roleID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function getRolesByRolename(roleName:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getRolesByRolename(roleName);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		
		
		
		public function updateUser(type:String, userID:String, password:String, fullName:String,
								   status:String, roleId:String, userAction:String, branch:String,
								   strPassNoEncrypt:String,
								   responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.updateUser(type, userID, password, fullName,
				status, roleId, userAction, branch, strPassNoEncrypt);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function deleteUser(userID:String, userAction:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.deleteUser(userID, userAction);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}	
		
		public function getMenuidByRoleid(roleID:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getMenuidByRoleid(roleID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function updateRole(roleID:String, roleName:String, description:String, menuList:String,
									userAction:String, p_add:String, p_delete:String, p_edit:String, p_view:String, p_approve:String,
									p_export:String, p_import:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.updateRole(roleID, roleName, description, menuList, userAction, p_add, p_delete, p_edit, p_view, p_approve, p_export,p_import);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		public function deleteRole(roleID:String, userAction:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.deleteRole(roleID, userAction);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}
		
		
		public function deleteAccount(casaacc:String, userAction:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.deleteAccount(casaacc, userAction);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}		
		
		public function getParentFullChild(roleID:String, responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken  = ro.getParentFullChild(roleID);
			if( responder != null )
				asyncToken.addResponder(responder);	    
		}		
	}
}